using System;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows.Shapes;
namespace MicroMsg.UI.UserContrl
{
	public class TreeHelper
	{
		private static int _counter;
		public static void Dump()
		{
			TreeHelper.Dump((FrameworkElement)Application.get_Current().get_RootVisual(), 0, 0);
		}
		private static bool DoesBrushHavePixels(Brush brush_0)
		{
			SolidColorBrush solidColorBrush = brush_0 as SolidColorBrush;
			return brush_0 != null && (solidColorBrush == null || solidColorBrush.get_Color() != Colors.get_Transparent());
		}
		private static Brush GetBackgroundBrush(FrameworkElement frameworkElement_0)
		{
			PropertyInfo property = frameworkElement_0.GetType().GetProperty("Background");
			object obj = (property == null) ? null : property.GetGetMethod().Invoke(frameworkElement_0, new object[0]);
			return obj as Brush;
		}
		private static bool IsBorderWithBorder(FrameworkElement frameworkElement_0)
		{
			Border border = frameworkElement_0 as Border;
			return border != null && TreeHelper.DoesBrushHavePixels(border.get_BorderBrush());
		}
		private static void Dump(FrameworkElement frameworkElement_0, int treeDepth, int layerDepth)
		{
			if (frameworkElement_0.get_Visibility() == 1)
			{
				return;
			}
			Rect layoutSlot = LayoutInformation.GetLayoutSlot(frameworkElement_0);
			GeneralTransform generalTransform = frameworkElement_0.TransformToVisual(null);
			generalTransform.Transform(new Point(0.0, 0.0));
			Rect rect = generalTransform.TransformBounds(layoutSlot);
			Rect rect2 = new Rect(0.0, 0.0, 480.0, 800.0);
			rect2.Intersect(rect);
			if (!rect2.get_IsEmpty())
			{
				double arg_82_0 = rect2.get_Width();
				double arg_8A_0 = rect2.get_Height();
			}
			string arg_91_0 = frameworkElement_0.get_Name();
			if ((!(frameworkElement_0 is Control) && TreeHelper.DoesBrushHavePixels(TreeHelper.GetBackgroundBrush(frameworkElement_0))) | TreeHelper.IsBorderWithBorder(frameworkElement_0) | (frameworkElement_0 is Shape || frameworkElement_0 is TextBlock || frameworkElement_0 is TextBox))
			{
				layerDepth++;
			}
			CacheMode arg_D9_0 = frameworkElement_0.get_CacheMode();
			TreeHelper._counter++;
			int childrenCount = VisualTreeHelper.GetChildrenCount(frameworkElement_0);
			for (int i = 0; i < childrenCount; i++)
			{
				TreeHelper.Dump((FrameworkElement)VisualTreeHelper.GetChild(frameworkElement_0, i), treeDepth + 1, layerDepth);
			}
		}
	}
}
